package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.UserQuery;
import com.gec.zhs.entity.po.User;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户基本信息表 Controller
 */
@RestController("userController")
@RequestMapping("/user")
public class UserController extends ABaseController{

	@Resource
	private UserService userService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(UserQuery query){
		return getSuccessResponseVO(userService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(User bean) {
		userService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<User> listBean) {
		userService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<User> listBean) {
		userService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getUserById")
	public ResponseVO getUserById(String id) {
		return getSuccessResponseVO(userService.getUserById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateUserById")
	public ResponseVO updateUserById(User bean,String id) {
		userService.updateUserById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteUserById")
	public ResponseVO deleteUserById(String id) {
		userService.deleteUserById(id);
		return getSuccessResponseVO(null);
	}
}